<template>
    <a-spin :spinning="!load">
        <a-drawer title="岗位列表" placement="right" :closable="false" :visible="show" @close="onClose" width="500">
            <!-- S-表格 -->
            <a-table :columns="columns" :data-source="data" bordered :pagination="false"></a-table>
            <!-- E-表格 -->
            <div :style="{
          position: 'absolute',
          bottom: 0,
          width: '100%',
          borderTop: '1px solid #e8e8e8',
          padding: '10px 16px',
          textAlign: 'right',
          left: 0,
          background: '#fff',
          borderRadius: '0 0 4px 4px',
        }">
                <a-button type="primary" @click="show = false">
                    关闭
                </a-button>
            </div>
        </a-drawer>
    </a-spin>
</template>
<script>
    import { getDeptStation } from "@/services"
    export default {
        data() {
            return {
                // 是否显示
                show: false,
                // 是否加载完成
                load: true,
                // 父级数据
                parent: {},
                // 岗位列表
                data: [],
                // 结构
                columns: [
                    {
                        title: 'station',
                        dataIndex: 'station',
                        key: 'station',
                    },
                    {
                        title: 'stationName',
                        dataIndex: 'stationName',
                        key: 'stationName',
                    }],
            }
        },
        methods: {
            /**
             * 打开抽屉
             */
            open(e) {
                this.show = true
                this.load = false
                this.parent = e
                this.fetchList()
            },
            showDrawer() {
                this.show = true;
            },
            onClose() {
                this.show = false;
            },
            /**
             * 获取列表
             */
            async fetchList() {
                this.load = false
                let { code, data } = await getDeptStation({
                    deptId: this.parent?.id
                })
                this.load = true
                if (code == 200) {
                    this.data = data
                }
            }
        },
    }
</script>